<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        html {
            height: 100%;
        }

        body {
            background: url(img/bg.jpeg);
            height: 100%;
        }

        .box {
            width: 400px;
            height: 330px;
            background-color: white;
            border-radius: 10px;
            margin: 100px auto;
        }

        .wenzi {
            height: 80px;
            background-color: #87cefa;
            border-radius: 10px 10px 0 0;
            text-align: center;
            line-height: 80px;
            font-size: 20px;
            color: white;
        }

        .box input {
            width: 240px;
            height: 30px;
            border: 1px solid #eee;
            border-radius: 5px;
            padding-left: 10px;
        }

        .box .xinx div {
            margin-top: 20px;
            margin-left: 70px;
        }

        .box .xinx .d1 {
            width: 240px;
            height: 30px;
            font-size: 16px;
            color: #ccccd6;
            display: flex;
            justify-content: space-between;
        }

        .box .xinx button {
            width: 80px;
            height: 40px;
            background-color: #90ee90;
            border: none;
            font-size: 16px;
            color: white;
            border-radius: 5px;
            margin: 15px 160px;
        }
        a {
            text-decoration: none;
            color: #555;
            font-size: 16px;
            color: #ccccd6;
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="wenzi">欢迎登录后台管理系统</div>
        <div class="xinx">
            <div><input type="text" placeholder="输入用户名"></div>
            <div><input type="password" placeholder="输入密码"></div>
            <div class="d1"><a href="./注册.html">去注册</a><span>忘记密码</span></div>
            <button>登录</button>
        </div>
    </div>
</body>

</html>
<script src="./axios.min.js"></script>
<script>
    var inputs = document.querySelectorAll('.box .xinx input')
    var btn = document.querySelector('button')
    btn.onclick = () => {
        console.log(location.href = './首页.html');
        axios.post('/user/login', { phone: inputs[0].value, pass: inputs[1].value }).then((res) => {
            if (res.data.code == 200) {
                localStorage.setItem('userinfo',JSON.stringify(res.data.userinfo))
                localStorage.setItem('token',res.data.token)
                alert(res.data.msg)
                location.href = './首页.html'
            } else {
                alert(res.data.msg)
            }
        })
    }
</script>